home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / dist.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  69 lines

  1. ; $Id: dist.pro,v 1.4 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1982-1997, Research Systems, Inc.  All rights reserved.
  4. ;    Unauthorized reproduction prohibited.
  5. ;
  6.  
  7. function dist,n,m  ;Return a rectangular array in which each pixel = euclidian
  8.         ;distance from the corner.
  9. ;+
  10. ; NAME:
  11. ;    DIST
  12. ;
  13. ; PURPOSE:
  14. ;    Create a rectangular array in which each element is proportional
  15. ;    to its frequency.  This array may be used for a variety
  16. ;    of purposes, including frequency-domain filtering and
  17. ;    making pretty pictures.
  18. ;
  19. ; CATEGORY:
  20. ;    Signal Processing.
  21. ;
  22. ; CALLING SEQUENCE:
  23. ;    Result = DIST(N [, M])
  24. ;
  25. ; INPUTS:
  26. ;    N = number of columns in result.
  27. ;    M = number of rows in result.  If omitted, N is used to return
  28. ;        a square array.
  29. ;
  30. ; OUTPUTS:
  31. ;    Returns an (N,M) floating array in which:
  32. ;
  33. ;    R(i,j) = SQRT(F(i)^2 + G(j)^2)   where:
  34. ;         F(i) = i  IF 0 <= i <= n/2
  35. ;              = n-i  IF i > n/2
  36. ;         G(i) = i  IF 0 <= i <= m/2
  37. ;              = m-i  IF i > m/2
  38. ;
  39. ; SIDE EFFECTS:
  40. ;    None.
  41. ;
  42. ; RESTRICTIONS:
  43. ;    None.
  44. ;
  45. ; PROCEDURE:
  46. ;    Straightforward.  The computation is done a row at a time.
  47. ;
  48. ; MODIFICATION HISTORY:
  49. ;    Very Old.
  50. ;     SMR, March 27, 1991 - Added the NOZERO keyword to increase efficiency.
  51. ;                (Recomended by Wayne Landsman)
  52. ;    DMS, July, 1992.  - Added M parameter to make non-square arrays.
  53. ;-
  54. on_error,2              ;Return to caller if an error occurs
  55. x=findgen(n)        ;Make a row
  56. x = (x < (n-x)) ^ 2    ;column squares
  57. if n_elements(m) le 0 then m = n
  58.  
  59. a = FLTARR(n,m,/NOZERO)    ;Make array
  60.  
  61. for i=0L, m/2 do begin    ;Row loop
  62.     y = sqrt(x + i^2) ;Euclidian distance
  63.     a[0,i] = y    ;Insert the row
  64.     if i ne 0 then a[0, m-i] = y ;Symmetrical
  65.     endfor
  66. return,a
  67. end
  68.  
  69.